﻿using IterationLife.FootballTeaching.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings {
    /// <summary>
    /// 课程分类数据传输对象扩展
    /// </summary>
    public static class CourseCategoryDtoExtension {
        /// <summary>
        /// 转换为课程分类实体
        /// </summary>
        /// <param name="dto">课程分类数据传输对象</param>
        public static CourseCategory ToEntity( this CourseCategoryDto dto ) {
            if ( dto == null )
                return new CourseCategory();
            return dto.MapTo( new CourseCategory( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为课程分类数据传输对象
        /// </summary>
        /// <param name="entity">课程分类实体</param>
        public static CourseCategoryDto ToDto(this CourseCategory entity) {
            if( entity == null )
                return new CourseCategoryDto();
            return entity.MapTo(new CourseCategoryDto());
        }
    }
}
